package com.jd.dlc.autoconfigure;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * @program: dlc
 * @ClassName DlcProperties
 * @description: Dlc configuration class
 * @author: sizegang
 **/
@ConfigurationProperties(prefix = DlcProperties.PREFIX)
@Component
public class DlcProperties {

    public static final String PREFIX = "dlc";

    /**
     * Compatible with M station details
     * The task scheduling engine gobrs-async will interrupt the task flow
     */
    private boolean interrupt = false;

    private Cache cache;

    private Jimdb jimdb;

    private Limiter limiter;


    public boolean isInterrupt() {
        return interrupt;
    }

    public void setInterrupt(boolean interrupt) {
        this.interrupt = interrupt;
    }

    public static class Cache {
        private Integer lockCycleTime = 20;

        private Integer recursionTime = 1000;

        private String accessCacheKey;


        public Integer getLockCycleTime() {
            return lockCycleTime;
        }

        public void setLockCycleTime(Integer lockCycleTime) {
            this.lockCycleTime = lockCycleTime;
        }

        public String getAccessCacheKey() {
            return accessCacheKey;
        }

        public void setAccessCacheKey(String accessCacheKey) {
            this.accessCacheKey = accessCacheKey;
        }


        public Integer getRecursionTime() {
            return recursionTime;
        }

        public void setRecursionTime(Integer recursionTime) {
            this.recursionTime = recursionTime;
        }
    }

    public static class Jimdb {
        private boolean enabled;
        private String jimUrl;
        private String configId;
        /**
         * 分布式锁出现问题自动报警 对应的key
         */
        private String umpAlarmKey;
        /*** 释放锁的脚本sha1的结果值*/
        private String releaseScriptSha = "e9f69f2beb755be68b5e456ee2ce9aadfbc4ebf4";
        /**
         * 锁续期的脚本sha1的结果值
         */
        private String renewExpirationScriptSha = "9136fcf51831e5cf49f109b6e9c97d5b675280d6";

        public String getUmpAlarmKey() {
            return umpAlarmKey;
        }

        public void setUmpAlarmKey(String umpAlarmKey) {
            this.umpAlarmKey = umpAlarmKey;
        }

        public String getReleaseScriptSha() {
            return releaseScriptSha;
        }

        public void setReleaseScriptSha(String releaseScriptSha) {
            this.releaseScriptSha = releaseScriptSha;
        }

        public String getRenewExpirationScriptSha() {
            return renewExpirationScriptSha;
        }

        public void setRenewExpirationScriptSha(String renewExpirationScriptSha) {
            this.renewExpirationScriptSha = renewExpirationScriptSha;
        }

        public String getJimUrl() {
            return jimUrl;
        }

        public void setJimUrl(String jimUrl) {
            this.jimUrl = jimUrl;
        }

        public String getConfigId() {
            return configId;
        }

        public void setConfigId(String configId) {
            this.configId = configId;
        }

        public boolean isEnabled() {
            return enabled;
        }

        public void setEnabled(boolean enabled) {
            this.enabled = enabled;
        }
    }

    public static class Limiter{
        private boolean enabled;

        private long gaKeySize;

        private long gaKeyTimeout;

        private String type;

        private String[] sannerPath;

        public String[] getSannerPath() {
            return sannerPath;
        }

        public void setSannerPath(String[] sannerPath) {
            this.sannerPath = sannerPath;
        }

        public boolean isEnabled() {
            return enabled;
        }

        public void setEnabled(boolean enabled) {
            this.enabled = enabled;
        }

        public long getGaKeySize() {
            return gaKeySize;
        }

        public void setGaKeySize(long gaKeySize) {
            this.gaKeySize = gaKeySize;
        }

        public long getGaKeyTimeout() {
            return gaKeyTimeout;
        }

        public void setGaKeyTimeout(long gaKeyTimeout) {
            this.gaKeyTimeout = gaKeyTimeout;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }
    }



    public Jimdb getJimdb() {
        return jimdb;
    }

    public void setJimdb(Jimdb jimdb) {
        this.jimdb = jimdb;
    }

    public Cache getCache() {
        return cache;
    }

    public void setCache(Cache cache) {
        this.cache = cache;
    }

    public Limiter getLimiter() {
        return limiter;
    }

    public void setLimiter(Limiter limiter) {
        this.limiter = limiter;
    }

}
